<template>
  <div class="btn">
    <t-descriptions :column="1" :layout="vertical" 
    :label-style="{ width: '44.2%', textAlign: 'right' }"
    :content-style="{ textAlign: 'left' }">
      <t-descriptions-item label="申报时间">{{ projectDetail?.planShengBaoYear }} {{ jdList.find(item => item.value === projectDetail?.planShengBaoQuarter)?.label || '未知季度' }}</t-descriptions-item>
      <t-descriptions-item label="报告完成时间">{{ projectDetail?.reportCompleteTime }}</t-descriptions-item>
    </t-descriptions>
    <t-space style="margin-top: 16px;">
      <t-button  :loading="loading" @click="onSumbit" :disabled="projectDetail?.approvalProcess > 0">确定</t-button>
      <t-button  theme="default" variant="base"  @click="onCancel">取消</t-button>
    </t-space>
  </div>
</template>
<script setup>
import { useRouter } from "vue-router";
import { approvalCPlan } from "@/api/sjhg/approval";
import { MessagePlugin } from "tdesign-vue-next";
const router = useRouter();
const props = defineProps({
  projectDetail: {
      type: Object,
      default: () => {},
    },
})
const loading = ref(false)
//季度
const jdList = [
  {value:'1',label:'第一季度/批次'},
  {value:'2',label:'第二季度/批次'},
  {value:'3',label:'第三季度/批次'},
  {value:'4',label:'第四季度/批次'}
]

//取消
const onCancel = () => {
    router.push({ path: "/homine/index" });
};
//确定
const emit = defineEmits(["goNext"]);
//确认工作计划
const onSumbit = () => {
  loading.value = true
   const params = {
    assessId : props.projectDetail?.id
   }
   try{
    approvalCPlan(params)
      .then((res) => {
        if (res.code == 200) {
           MessagePlugin.success(res.data);
           emit('goNext',props.projectDetail.id)
        }
      }).finally(() => {
         loading.value = false
      });
    }  catch (error) {
      loading.value = false
    }
 
};
</script>
<style lang="scss" scoped>
:deep(.t-descriptions__body.t-size-m > tbody > tr > td ){
  padding: 0px 16px 16px 0;
}
.btn{
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin-top: 24px;
}
</style>
